/*
 * Money.cpp
 *
 *  Created on: May 2, 2011
 *      Author: default
 */

#include <iostream>
#include "Money.h"
#include "MainGame.h"

static const int Money_Y = 935;
using namespace std;

SDL_Surface *Money::load_text(const string &text){
	SDL_Surface *text_message = TTF_RenderText_Solid(font, text.c_str(), textColor);
	if(text_message == NULL){
		std :: cerr << "Error in load_text \"" << text << "\" : " << TTF_GetError() << std :: endl;
	}

	return text_message;
}

bool Money::init(){

	if( TTF_Init() == -1 )
	{
		return false;
	}

	SDL_Color _text_color = {255, 255, 255};
	textColor = _text_color;

	if((font = TTF_OpenFont( "fonts/andy.ttf", 24 )) == NULL){
		std :: cerr << "Error in TTF_OpenFont : " << TTF_GetError () << std :: endl;
	}

	eState = sIntro;
	m_Muony = NULL;
	m_Bet = NULL;
	m_Win = NULL;
	m_Coin_Value = NULL;
	m_Coin = NULL;
	m_fCoin = NULL;

	return 0;
}

string Money :: AddMoney(float update){
	i_AddMoney += update;
	string tmp;
	ostringstream out;
	out << i_AddMoney;
	tmp = out.str();
	return tmp;
}

void Money::ChangeMoney(){
	s_AddMoney = AddMoney(2);
	m_Muony = load_text(s_AddMoney + ".00");

	m_Coin_Value = load_text("0.20");
	m_Bet = load_text("0.20");
	m_Win = load_text("0.00");
	m_fCoin = i_AddMoney * 5;
	//m_Coin = load_text();
	cout << m_fCoin << endl;
}

string Money::ChangeBet(float fbet){



}

void Money::onDraw(){

	apply_surface( 434, Money_Y, m_Muony, gMainGame.m_Screen );
	apply_surface( 654, Money_Y, m_Bet, gMainGame.m_Screen );
	apply_surface( 904, Money_Y, m_Win, gMainGame.m_Screen );

	apply_surface( 1100, 880, m_Coin_Value, gMainGame.m_Screen );
	apply_surface( 1030, 800, m_Coin, gMainGame.m_Screen );

}

